import { createRouter, createWebHashHistory } from 'vue-router'
import routes from './routes'
import { useAnswerStore } from '../stores/modules/answer'


const router = createRouter({
    history: createWebHashHistory(),
    routes
})
router.beforeEach((to, from, next) => {
    const isFromAnswerRouter = from.fullPath.startsWith('/answer')
    if (isFromAnswerRouter) {
        // 离开答题页面把答题的记录清空
        const answerStore = useAnswerStore();
        answerStore.clearAnswerData();
    }
    next();
})
export default router